package jmine.tec.report.impl.table.pdf;

import jmine.tec.report.api.table.ReportCell;
import jmine.tec.report.impl.table.RendererParameterInterface;
import jmine.tec.report.impl.table.ReportTableBuilder;

import com.lowagie.text.Element;

/**
 * Implementação default de formatter de células de relatório
 * 
 * @author lundberg
 */
public class StringCellPDFRenderer extends AbstractCellPDFRenderer {

    /**
     * {@inheritDoc}
     */
    public String getRendererType() {
        return ReportTableBuilder.TYPE_STRING;
    }

    /**
     * {@inheritDoc}
     */
    public String getFormattedString(ReportCell cell) {
        if (cell.getValue() == null) {
            return "";
        } else {
            return cell.getValue().toString();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected int getHorizontalAlignment(RendererParameterInterface rpi) {
        if (rpi.getIsHeader()) {
            if (rpi.isNumberColumnHeader() || rpi.isPorcentagemColumnHeader()) {
                return Element.ALIGN_RIGHT;
            } else if (rpi.isDateColumnHeader()) {
                return Element.ALIGN_CENTER;
            }
        }
        return Element.ALIGN_LEFT;
    }
}
